package org.goyo.main.domain.dao.base.impl;

import org.apache.commons.lang.StringUtils;
import org.goyo.common.exception.DBException;
import org.goyo.common.utils.Pager;
import org.goyo.main.domain.dao.BaseDAO;
import org.goyo.main.domain.dao.base.ICustomerDao;
import org.springframework.stereotype.Repository;

@Repository
public class CustomerDaoImpl extends BaseDAO implements ICustomerDao{

	@Override
	public Pager findByCond(String cond, Pager pager) throws DBException {
		StringBuffer buf = new StringBuffer("from Customer where 1=1 ");
		if (StringUtils.isNotBlank(cond)) {
		  buf.append(" and ");
          buf.append(cond);
		}
		    String hql = this.addSort(buf, pager);
		    String countHql = "select count(*) "+buf.toString();
		 return this.findObjectsByPager(hql,countHql, pager);
	}

}
